package com.gsit.ocrbatch.utils;

import java.util.ArrayList;
import java.util.List;

import com.gsit.ocrbatch.domain.RecordReject;
import com.gsit.ocrbatch.domain.RejectState;

public final class MessageUtil {
	
	private static final List<RecordReject> recordRejects = new ArrayList<>();
	
	static{
		recordRejects.add(new RecordReject("Merchange name is incorrect.",RejectState.NAME));
		recordRejects.add(new RecordReject("Amount is incorrect.",RejectState.AMOUNT));
		recordRejects.add(new RecordReject("Currency is incorrect.",RejectState.CURRENCY));
		recordRejects.add(new RecordReject("Date is incorrect.",RejectState.DATE));
		recordRejects.add(new RecordReject("Should be Bad quality.",RejectState.BAD));
		
	}
	
	public static final List<RecordReject> getAllRecordRejects() {
		return recordRejects;
	}
	
	public static final String getMessage(List<RecordReject> recordRejects) {
		StringBuffer buffer = new StringBuffer();
		if(recordRejects == null )return buffer.toString();
		for (RecordReject recordReject : recordRejects) {
			buffer.append(getMessage(recordReject.getRejectState()));
			buffer.append("  ||||  ");
		}
			
		return buffer.toString();
	}
	
	public static final String getMessage(RejectState rejectState) {
		StringBuffer buffer = new StringBuffer();
		for (RecordReject recordReject : recordRejects) {
				if(recordReject.getRejectState()==rejectState){
					buffer.append(recordReject.getMessage());
					break;
				}
			
		}
		return buffer.toString();
	}
	
	public static final List<String> getMessageList(List<RecordReject> recordRejects) {
		List<String> messages = new ArrayList<>();
		if(recordRejects == null )return messages;
		for (RecordReject recordReject : recordRejects) {
			messages.add(getMessage(recordReject.getRejectState()));
		}
			
		return messages;
	}

}
